<?php

namespace App\Models;

use DateTimeInterface;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class Venue
 * *
 * @property $id  自增ID
 * @property $name  场馆名称
 * @property $desc  简介
 * @property $image  图片
 * @property $meet_cancel_set  取消设置 0=不允,1=允许,2=仅开始前可取消
 * @property $meet_status  状态 0=未启用,1=使用中,9=停止预约,10=已关闭
 * @property $meet_max_join  预约最大人数
 * @property $info  场馆信息
 * @property $publisher_uid  发布者uid
 * @property $created_at
 * @property $updated_at
 * @property $deleted_at
 *
 * @package  App\Models
 * @mixin \Illuminate\Database\Eloquent\Builder
 */
class Venue extends Model
{
    use SoftDeletes;

    protected $table = 'venues';

    protected $casts = [
        'info' => 'array',
    ];

    protected $fillable = ['id', 'name', 'desc', 'image', 'meet_cancel_set', 'meet_status', 'meet_max_join', 'info', 'publisher_uid'];
    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
    }

    public function days()
    {
        return $this->hasMany(MeetDay::class, 'venue_id');
    }
}
